#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
#define int long long
#define x first
#define y second
using namespace std;
const int N = 2e5 + 10;
int n;
vector<vector<int>> G(N,vector<int>());//开二维数组
//vector<int> G[N];
int ans[N];
/* void dfs(int u,int fa)
{
    for(auto v:G[u])
    {
        if(v == fa)
        {
            ans[v] += G[u].size() - 1;
            continue;
        }
        dfs(v,u);
        ans[v] += G[u].size() - 1;
    }
} */
void solve()
{
    cin >> n;
    for(int i = 1; i < n; i++) 
    {
        int u,v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    /* dfs(1,0);
    for(int i = 1; i <= n; i++) 
    cout << ans[i] << " ";
    cout << endl; */
    for(int i = 1; i <= n; i++)
    {
        int t = 0;
        for(int v : G[i]) t = t + G[v].size(); //邻居的度(但是每个邻居的度都包含自己)
        cout << t - G[i].size() << " ";  //(所以和减去自己的度)
    }
   /*  for(int i = 1; i <= n; i++)
    {
        int t = 0;
        for(int v : G[i]) t += G[v].size() - 1; 
        cout << t  << " ";  
    } */
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    /* cin >> t; */
    while(t -- )  solve();
    return 0;
}